#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@Author: kindey
@Date: 2025/8/7
@Description: 
"""
from rest_framework import serializers
from apps.models.data_model import Data
from apps.models.dic_small_class_model import DictSmallClass

class DataSerializer(serializers.ModelSerializer):
    class Meta:
        model = Data
        fields = '__all__'

class DataCreateSerializer(serializers.ModelSerializer):
    class Meta:
        model = Data
        fields = '__all__'
        read_only_fields = ('id',)

class DataDetailSerializer(serializers.ModelSerializer):
    """
    对应复杂查询的序列化器
    """
    data_time = serializers.DateTimeField()
    data_value = serializers.DecimalField(max_digits=6, decimal_places=2)
    dev_type = serializers.CharField()
    dev_name = serializers.CharField()
    dev_type2 = serializers.CharField()
    reg_name = serializers.CharField()
    data_id = serializers.IntegerField()
    dev_id = serializers.IntegerField()
    reg_id = serializers.IntegerField()

    class Meta:
        model = Data
        fields = [
            'data_time', 'data_value', 'dev_type', 'dev_name',
            'dev_type2', 'reg_name', 'data_id', 'dev_id', 'reg_id'
        ]
class DictSmallClassSerializer(serializers.ModelSerializer):
    class Meta:
        model = DictSmallClass
        fields = '__all__'

class DeviceWithRegionInfoSerializer(serializers.Serializer):
    """
    设备区域信息统计序列化器
    """
    reg_name = serializers.CharField()
    dict_name = serializers.CharField()
    records = serializers.IntegerField()
    start_time = serializers.DateTimeField()
    end_time = serializers.DateTimeField()
    cid = serializers.IntegerField()
    bid = serializers.IntegerField()